import React from 'react'
import PropTypes from 'prop-types'
import IMG_LOADING from 'image/page/loading.png'
import styles from './Loading.styl'

const Loading = ({ loading = true, style = {}, children }) =>
    (loading ? (
        <div className={styles.loading} style={style}>
            <img src={IMG_LOADING} alt="加载中..." />
            <div className={styles['loading-text']}>用力加载中，请稍等</div>
        </div>
    ) : children)

Loading.defaultProps = {
    loading: true,
    style: {},
}

Loading.propTypes = {
    loading: PropTypes.bool,
    style: PropTypes.object,
}

export default Loading
